package org.come.Jpanel;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.BorderFactory;
import javax.swing.GrayFilter;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JPasswordField;

import com.tool.btn.FormsOnOffBtn;
import com.tool.btn.RoleOperationPanelBtn;
import com.tool.tcpimg.UIUtils;
import com.updateNew.MyIsif;



public class UnLockJpanel extends JPanel implements MouseListener {

    private JPasswordField textUnlockpwd;// 解锁密码

    private RoleOperationPanelBtn btnSureunlock;// 确定解锁
    private RoleOperationPanelBtn btnSureunlock1;// 取消

    final ImageIcon imageIcon = new ImageIcon("img/123_副本.png");//解锁输入密码位置

    public UnLockJpanel() throws Exception {
        String style = MyIsif.getStyle();
        if ("水墨UI".equals(style)) {
    		this.setPreferredSize(new Dimension(534, 145));
            this.setLayout(null);
            this.setBackground(UIUtils.Color_BACK);

//            // 关闭按钮事件
//            FormsOnOffBtn offBtn = new FormsOnOffBtn("inkImg/old/2/1.png", 1, 33);
//            offBtn.setBounds(362 - 37, 10, 25, 25);
//            this.add(offBtn);

            // 解锁密码
            textUnlockpwd = new JPasswordField() {
                Image image = imageIcon.getImage();

                Image grayImage = GrayFilter.createDisabledImage(image);
                {
                    setOpaque(false);
                } // instance initializer

                @Override
                public void paint(Graphics g) {

                    // 背景图片
                    g.drawImage(grayImage, 0, 0, this);

                    super.paint(g);
                }
            };
            textUnlockpwd.setBounds(28, 88, 475, 16);
            textUnlockpwd.setForeground(Color.white);
            textUnlockpwd.setBackground(UIUtils.Color_BACK);
            textUnlockpwd.setBorder(BorderFactory.createEmptyBorder());
            textUnlockpwd.setCaretColor(Color.WHITE);
            textUnlockpwd.setFont(new Font("微软雅黑", 1, 16));
            this.add(textUnlockpwd);

            // 确定解锁
            btnSureunlock = new RoleOperationPanelBtn("skin/8100226/newbutton/B21.png", 1, "解  锁", null,null);
            btnSureunlock.setBounds(145, 110, 79, 24);

            this.add(btnSureunlock);
        btnSureunlock1 = new RoleOperationPanelBtn("skin/8100226/newbutton/B21.png", 1, "取  消", null,null);
        btnSureunlock1.setBounds(310, 110, 79, 24);
        this.add(btnSureunlock1);
        } else {
            this.setPreferredSize(new Dimension(534, 145));
            this.setLayout(null);
            this.setBackground(UIUtils.Color_BACK);

//            // 关闭按钮事件
//            FormsOnOffBtn offBtn = new FormsOnOffBtn("inkImg/old/2/1.png", 1, 33);
//            offBtn.setBounds(362 - 37, 10, 25, 25);
//            this.add(offBtn);

            // 解锁密码
            textUnlockpwd = new JPasswordField() {
                Image image = imageIcon.getImage();

                Image grayImage = GrayFilter.createDisabledImage(image);
                {
                    setOpaque(false);
                } // instance initializer

                @Override
                public void paint(Graphics g) {

                    // 背景图片
                    g.drawImage(grayImage, 0, 0, this);

                    super.paint(g);
                }
            };
            textUnlockpwd.setBounds(28, 88, 475, 16);
            textUnlockpwd.setForeground(Color.white);
            textUnlockpwd.setBackground(UIUtils.Color_BACK);
            textUnlockpwd.setBorder(BorderFactory.createEmptyBorder());
            textUnlockpwd.setCaretColor(Color.WHITE);
            textUnlockpwd.setFont(new Font("微软雅黑", 1, 16));
            this.add(textUnlockpwd);

            // 确定解锁
            btnSureunlock = new RoleOperationPanelBtn("inkImg/hongmu/1_png.button.btn_xy.png", 1, "解  锁", null,null);
            btnSureunlock.setBounds(145, 110, 79, 24);

            this.add(btnSureunlock);
            btnSureunlock1 = new RoleOperationPanelBtn("inkImg/hongmu/1_png.button.btn_xy.png", 1, "取  消", null,null);
            btnSureunlock1.setBounds(310, 110, 79, 24);
            this.add(btnSureunlock1);
        }
    }

    ImageIcon icon;

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        String style = MyIsif.getStyle();
        if ("水墨UI".equals(style)) {
        if (icon == null) {
        		 icon = new ImageIcon("inkImg/newbackground/B259.png");
        }
        	     // 道具栏
        g.drawImage(icon.getImage(), 0, 0, 534, 145, this);
        } else {
            if (icon == null) {
                icon = new ImageIcon("inkImg/newbackground/B259.png");
            }
            // 道具栏
            g.drawImage(icon.getImage(), 0, 0, 534, 145, this);
        }
    }

    @Override
    public void mouseClicked(MouseEvent e) {
        // TODO Auto-generated method stub

    }

    @Override
    public void mousePressed(MouseEvent e) {
        // TODO Auto-generated method stub

    }

    @Override
    public void mouseReleased(MouseEvent e) {

    }

    @Override
    public void mouseEntered(MouseEvent e) {
        // TODO Auto-generated method stub

    }

    @Override
    public void mouseExited(MouseEvent e) {
        // TODO Auto-generated method stub

    }

    public JPasswordField getTextUnlockpwd() {
        return textUnlockpwd;
    }

    public void setTextUnlockpwd(JPasswordField textUnlockpwd) {
        this.textUnlockpwd = textUnlockpwd;
    }

    public RoleOperationPanelBtn getBtnSureunlock() {
        return btnSureunlock;
    }

    public void setBtnSureunlock(RoleOperationPanelBtn btnSureunlock) {
        this.btnSureunlock = btnSureunlock;
    }

    public RoleOperationPanelBtn getBtnSureunlock1() {
        return btnSureunlock1;
    }

    public void setBtnSureunlock1(RoleOperationPanelBtn btnSureunlock1) {
        this.btnSureunlock1 = btnSureunlock1;
    }

}
